package com.ymatou.app.api.service;

import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;

/**
 * 根据主题Id获取主题商品信息列表Call FreeMaker Template自动生成代码
 */
public class TopicProductDetailsCall extends YmatouBaseCall {
	private static String opurl = "api/Group/TopicProductDetails";

	public TopicProductDetailsCall() {
		super(EnvSetup.getSystemUrl("api_app"), opurl, "GET", "PARAM");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept", "text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	/**
	 * 获取code
	 */
	public String getCode() {
		String Code = null;
		try {
			JSONObject jo = new JSONObject(getReturnData());
			Code = String.valueOf(jo.get("Code"));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}

	/**
	 * 获取BCode
	 */
	public String getBCode() {
		String BCode = null;
		try {
			JSONObject jo = new JSONObject(getReturnData());
			BCode = String.valueOf(jo.get("BCode"));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return BCode;
	}

	/**
	 * 获取Data
	 * 
	 * @return Data
	 */
	public JSONObject getData() {
		JSONObject Data = null;
		try {
			JSONObject jo = new JSONObject(getReturnData());
			Data = jo.getJSONObject("Data");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Data;
	}

	/**
	 * 获取Products
	 */
	public JSONObject getProducts() {
		JSONObject Products = null;
		try {
			Products = (JSONObject) getData().getJSONArray("Products").get(0);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Products;
	}

	/**
	 * 获取Product
	 */
	public JSONObject getProduct() {
		JSONObject Product = null;
		try {
			Product = getProducts().getJSONObject("Product");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Product;
	}

	/**
	 * 获取Catalogs
	 */
	public JSONObject getCatalogs() {
		JSONObject Catalogs = null;
		try {
			Catalogs = (JSONObject) getProduct().getJSONArray("Catalogs").get(0);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Catalogs;
	}

	/**
	 * 获取ProductId
	 */
	public String getProductId() {
		String ProductId = null;
		try {
			ProductId = getProducts().getString("ProductId");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ProductId;
	}

	/**
	 * 获取CatalogId
	 */
	public String getCatalogId() {
		String CatalogId = null;
		try {
			CatalogId = getCatalogs().getString("CatalogId");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return CatalogId;
	}

	/**
	 * 获取SellerId
	 */
	public int getSellerId() {
		int SellerId = 0;
		try {
			SellerId = getProduct().getInt("SellerId");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return SellerId;

	}

	/**
	 * 获取Msg
	 * 
	 * @return
	 */
	public String getMsg() {
		String Msg = null;
		try {
			JSONObject jo = new JSONObject(getReturnData());
			Msg = String.valueOf(jo.get("Msg"));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Msg;
	}
}